Skip to content

Spread CKS nodes of each type across hosts by default - #14763

Open
bhouse-nexthop wants to merge 1 commit into
apache:mainfrom
bhouse-nexthop:cks-default-anti-affinity
Open

bhouse-nexthop wants to merge 1 commit into
apache:mainfrom
bhouse-nexthop:cks-default-anti-affinity

Conversation

@bhouse-nexthop

Copy link
Copy Markdown
Collaborator

Description

New CKS clusters spread each node type across hosts by default. Builds on the per-node-type affinity groups from #12386.

Setting cloud.kubernetes.cluster.default.anti.affinity.enabled, account scope, default true
Group type non-strict host anti-affinity: nodes prefer different hosts and are never blocked, so fewer hosts than nodes still works
Group name cks-<cluster uuid>-<worker|control|etcd>, owned by the cluster owner
Which node types Workers always. Control and etcd only with 2+ nodes, since they can't be scaled
User groups If a node type already has a user-chosen group, no default is added for it
Scale / add node / replacement Uses the existing node-type affinity map, so they get the same group
Delete Removes the CKS groups after the cluster row, unless another cluster or a live VM still uses them. User groups are never touched
Processor excluded Skipped with a warning if NonStrictHostAntiAffinityProcessor is excluded
Existing clusters Not changed

Why default on: non-strict only changes host ordering in the planner and never fails a deploy. Without it, a single host failure can take out every control node or every etcd member.

Fixes: #14762

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

How Has This Been Tested?

  • Unit tests in KubernetesClusterManagerImplTest:
    • groups created per node type, user groups kept, single control/etcd skipped
    • skipped when disabled or processor missing
    • delete: only CKS non-strict groups, kept when another cluster or a live VM uses them
  • Ran KubernetesClusterManagerImplTest, KubernetesClusterActionWorkerTest, KubernetesClusterScaleWorkerTest, KubernetesClusterResourceModifierActionWorkerTest: all pass

How did you try to break this feature and the system with this change?

  • Fewer hosts than nodes: non-strict, and the CKS capacity pre-check ignores this type
  • updateKubernetesClusterAffinityGroups replaces the map as before; any default groups it drops are still deleted with the cluster
  • A cluster VM that fails to expunge (Destroyed/Error) doesn't keep the group around

When a node type has no user-chosen affinity group, a new cluster gets a
non-strict host anti-affinity group for it, so one host failure doesn't
take out the whole control plane or every etcd member.

- New account-scoped setting cloud.kubernetes.cluster.default.anti.affinity.enabled (default true)
- Non-strict: nodes prefer different hosts; deploy and scale still work with fewer hosts than nodes
- Groups: cks-<cluster uuid>-<worker|control|etcd>; control/etcd only with 2+ nodes (they don't scale)
- User-chosen groups for a node type win; no default added for it
- Stored in the existing node-type affinity map, so scale, add-node and replacement reuse them
- Deleted with the cluster unless another cluster or a live VM still uses them
- Skipped if the non-strict processor is excluded; existing clusters untouched

Signed-off-by: Brad House <bhouse@nexthop.ai>
@codecov

codecov Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 74.60317% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 20.81%. Comparing base (2737087) to head (9e2b2c9).

Files with missing lines Patch % Lines
.../dao/KubernetesClusterAffinityGroupMapDaoImpl.java 0.00% 8 Missing ⚠️
...bernetes/cluster/KubernetesClusterManagerImpl.java 86.53% 7 Missing ⚠️
.../actionworkers/KubernetesClusterDestroyWorker.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##               main   #14763     +/-   ##
===========================================
  Coverage     20.80%   20.81%             
- Complexity    20919    20942     +23     
===========================================
  Files          6053     6053             
  Lines        548451   548513     +62     
  Branches      78719    73289   -5430     
===========================================
+ Hits         114128   114193     +65     
+ Misses       420958   420956      -2     
+ Partials      13365    13364      -1     
Flag Coverage Δ
uitests 3.86% <ø> (ø)
unittests 22.25% <74.60%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CKS: spread control, etcd and worker nodes across hosts by default

1 participant